Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HHH-15846 Option to add @SuppressFBWarnings annotation on generated code #5790

Closed
wants to merge 1 commit into from

Conversation

NicklasWallgren
Copy link

@NicklasWallgren NicklasWallgren commented Dec 17, 2022

Lombok has an option to add @SuppressFBWarnings to generated code via lombok.extern.findbugs.addSuppressFBWarnings.

It would be really helpful if the hibernate gradle/maven enhance plugins would provide a similar option.

We're currently struggling with warnings related to hibernate generated code in our entities, in SpotBugs.

NP | Non-null field $_hibernate_attributeInterceptor is not initialized by new <entity>
NP | Non-null field $_hibernate_entityEntryHolder is not initialized by new <entity>
NP | Non-null field $_hibernate_nextManagedEntity is not initialized by new <entity>
NP | Non-null field $_hibernate_previousManagedEntity is not initialized by new <entity>
NP | Non-null field $_hibernate_tracker is not initialized by new <entity>

Discussion on GitHub
Enhance plugin - Option to add @SuppressFBWarnings annotation · Discussion #5668 · hibernate/hibernate-orm

/**
* @see "https://spotbugs.readthedocs.io/en/latest/bugDescriptions.html"
*/
String[] value();
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might be able to remove value(). It works fine without it.

@hibernate-github-bot
Copy link

hibernate-github-bot bot commented Dec 17, 2022

Thanks for your pull request!

This pull request appears to follow the contribution rules.

› This message was automatically generated.

@NicklasWallgren
Copy link
Author

@gavinking Are you able to review this PR, or any of the other contributors? 🙂
Thanks

@gavinking
Copy link
Member

gavinking commented Dec 23, 2022

@gavinking Are you able to review this PR, or any of the other contributors? 🙂
Thanks

Hi, I don't know what @SuppressFBWarnings is, nor why you want this, and neither the JIRA issue nor the discussion explain it...

@NicklasWallgren
Copy link
Author

NicklasWallgren commented Dec 23, 2022

@gavinking Are you able to review this PR, or any of the other contributors? 🙂
Thanks

Hi, I don't know what @SuppressFBWarnings is, nor why you want this, and neither the JIRA issue nor the discussion explain it...

Ah sorry, I got you mixed up with @Sanne.
The annotation is used to suppress any warnings found by FindBugs or SpotBugs.

@sebersole
Copy link
Member

@NicklasWallgren Can you rebase this on main? And I will take a look.

@sebersole
Copy link
Member

Also, the discussion mentioned @Generated but I do not see that handled here. Is that a different PR or just not added?

@sebersole
Copy link
Member

@NicklasWallgren Could you explain how an annotation you are adding into Hibernate here in this PR somehow affects those other libraries? How do FindBugs, etc know to look for this annotation?

Could we not just leverage java.lang.SuppressWarnings for this?

@gavinking
Copy link
Member

@NicklasWallgren has not responded to Steve's questions, and the branch now has conflicts, so perhaps we can just close this?

@beikov
Copy link
Contributor

beikov commented Sep 13, 2024

Please create a new PR once you're willing to fixup the issues.

@beikov beikov closed this Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants